// 遍历显示西城聚焦部分的标题背景颜色
window.onload = () => {
    let titleList = document.querySelectorAll("h1");
    let colorArr = ["rgba(238,139,20,0.5)","rgba(77,166,219,0.5)","rgba(10,148,80,0.5)","rgba(171,85,84,0.5)"];
    let j = 0;
    for (let i = 0;i < titleList.length;i++){
        titleList[i].style.backgroundColor = colorArr[j];
        j++;
        if(j === 4){
            j = 0;
        }
    }
};
// 回到顶部按钮
let backT = document.querySelector("#backBtn");
window.onscroll = () => {
    let backY = document.documentElement.scrollTop || document.body.scrollTop;
    if(backY > 500){
        backT.style.opacity = "1";
    }else{
        backT.style.opacity = "0";
    }
    backT.addEventListener('click',() => {
        window.scrollTo({
            top:0,
            behavior:"smooth"
        });
    });
};


